<?=
get_toolbar(array('accion' => 'custom',
    'botones' => '<a href="' . site_url(get_uri_string() . "/paso1") . '" class="btn btn-success color-blanco">' . ulang('crear_una_nueva_empresa') . '</a>'));
?>
<?= get_alert(isset($success) ? $success : null, isset($error) ? $error : null); ?>
<div class="row">
    <div class="col-md-12">
        <!-- BEGIN SAMPLE TABLE PORTLET-->
        <div class="portlet box red">
            <div class="portlet-title">
                <div class="caption"><i class="icon-cogs"></i><?= ulang('empresas_creadas_por_ti') ?></div>
                <div class="tools">
                    <a href="javascript:;" class="collapse"></a>
                </div>
            </div>
            <div class="portlet-body">
                <div class="table-responsive">
                    <table class="table table-hover">
                        <thead>
                            <tr>
                                <th><?= ulang('emp_nombre') ?></th>
                                <th><?= ulang('emp_direccion') ?></th>
                                <th><?= ulang('mun_desc') ?></th>
                                <th><?= ulang('categorias') ?></th>
                                <th class="col-md-1"><?= ulang('emp_estado') ?></th>
                                <th class="col-md-2"><?= ulang('acciones') ?></th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($infoempresa as $empresa) { ?>
                                <tr>
                                    <td><?= $empresa['emp_nombre'] ?></td>
                                    <td><?= $empresa['emp_direccion'] ?></td>
                                    <td><?= $empresa['mun_desc'] ?></td>
                                    <td>
                                        <?php
                                        $categorias = array();
                                        foreach ($empresa['d_categorias'] as $cat) {
                                            $categorias[] = $cat['emc_slug'];
                                        }
                                        echo implode(",", $categorias);
                                        ?>
                                    </td>
                                    <td>
                                        <?php if ($empresa['emp_estado'] == 'P') { ?>
                                            <?php if($this->session->userdata('usu_fk_rol') < 3){?>
                                                <a href="<?=site_url(PANEL.'usuario/activar_empresa/'.$empresa['emp_id'])?>">
                                            <?php }?>
                                                <span class="label label-sm label-warning">Pendiente</span>
                                            <?php if($this->session->userdata('usu_fk_rol') < 3){?>
                                                </a>
                                            <?php }?>
                                        <?php } else if ($empresa['emp_estado'] == 'A') { ?>
                                            <?php if($this->session->userdata('usu_fk_rol') < 3){?>
                                                <a href="<?=site_url(PANEL.'usuario/desactivar_empresa/'.$empresa['emp_id'])?>">
                                            <?php }?>
                                                <span class="label label-sm label-success">Activo</span>
                                            <?php if($this->session->userdata('usu_fk_rol') < 3){?>
                                                </a>
                                            <?php }?>
                                        <?php } ?>
                                    </td>
                                    <td>
                                        <a class="btn btn-xs blue" href="<?= site_url(get_uri_string() . "/paso1/" . $empresa['emp_id']); ?>">
                                            <i class="icon-pencil"></i>
                                            Editar
                                        </a>
                                        <a class="btn btn-xs red" href="<?= site_url(get_uri_string() . "/borrar/" . $empresa['emp_id']) ?>" onclick="return confirm('<?= lang('mensaje_confirm_borrar') ?>')">
                                            <i class="icon-remove"></i>
                                            Borrar
                                        </a>
                                    </td>
                                </tr>
                            <?php } ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!-- END SAMPLE TABLE PORTLET-->
    </div>
</div>
<div class="row">
    <div class="col-md-12">
        <!-- BEGIN SAMPLE TABLE PORTLET-->
        <div class="portlet box purple">
            <div class="portlet-title">
                <div class="caption"><i class="icon-cogs"></i><?= ulang('tus_empresas') ?></div>
                <div class="tools">
                    <a href="javascript:;" class="collapse"></a>
                </div>
            </div>
            <div class="portlet-body">
                <div class="table-responsive">
                    <table class="table table-hover">
                        <thead>
                            <tr>
                                <th><?= ulang('emp_nombre') ?></th>
                                <th><?= ulang('emp_direccion') ?></th>
                                <th><?= ulang('mun_desc') ?></th>
                                <th><?= ulang('categorias') ?></th>
                                <th class="col-md-1"><?= ulang('emp_estado') ?></th>
                                <th class="col-md-2"><?= ulang('acciones') ?></th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($infoempresapropios as $empresa) { ?>
                                <tr>
                                    <td><?= $empresa['emp_nombre'] ?></td>
                                    <td><?= $empresa['emp_direccion'] ?></td>
                                    <td><?= $empresa['mun_desc'] ?></td>
                                    <td>
                                        <?php
                                        $categorias = array();
                                        foreach ($empresa['d_categorias'] as $cat) {
                                            $categorias[] = $cat['emc_slug'];
                                        }
                                        echo implode(",", $categorias);
                                        ?>
                                    </td>
                                    <td>
                                        <?php if ($empresa['emp_estado'] == 'P') { ?>
                                            <span class="label label-sm label-warning">Pendiente</span>
                                        <?php } else if ($empresa['emp_estado'] == 'A') { ?>
                                            <span class="label label-sm label-success">Activo</span>
                                        <?php } ?>
                                    </td>
                                    <td>
                                        <a class="btn btn-xs blue" href="<?= site_url(get_uri_string() . "/editar/paso1/" . $empresa['emp_id']); ?>">
                                            <i class="icon-pencil"></i>
                                            Editar
                                        </a>
                                        <a class="btn btn-xs red" href="<?= site_url(get_uri_string() . "/borrar/" . $empresa['emp_id']) ?>" onclick="return confirm('<?= lang('mensaje_confirm_borrar') ?>')">
                                            <i class="icon-remove"></i>
                                            Borrar
                                        </a>
                                    </td>
                                </tr>
                            <?php } ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!-- END SAMPLE TABLE PORTLET-->
    </div>
</div>